<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateAuditExam extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('audit_exam', ['comment' => '审核问卷表']);
        $table
            ->addColumn('industry_id', 'integer',array('limit' => 30,'default' => 0,'comment' => '行业类型id'))
            ->addColumn('unit_id', 'integer',array('limit' => 30, 'default' => 0,'comment' => '所属单位id'))
            ->addColumn('user_id', 'integer',array('limit' => 30, 'default' => 0,'comment' => '提交人id'))
            ->addColumn('status', 'boolean',array('limit' => 1, 'default' => 1, 'comment' => '审核状态(待审核or审核,1or2)'))
            ->addColumn('exam_id', 'integer',array('limit' => 50,'default' => 0,'comment' => '问卷id'))
            ->addColumn('start_time', 'integer',array('limit' => 150,'default' => 0,'comment' => '开始时间'))
            ->addColumn('end_time', 'integer',array('limit' => 150,'default' => 0,'comment' => '结束时间'))
            ->addColumn('audit_admin_id', 'integer',array('limit' => 30, 'default' => 0,'comment' => '审核人'))
            ->addColumn('audit_start_time', 'integer',array('limit' => 130, 'default' => 0,'comment' => '审核开始时间'))
            ->addColumn('audit_end_time', 'integer',array('limit' => 130, 'default' => 0,'comment' => '审核结束时间'))
            ->addColumn('exam_creation_type', 'boolean',array('limit' => 1, 'default' => 0, 'comment' => '试卷创建类型(人工创建or随机生成or一次生成全部,1or2or3)'))
            ->addColumn('duration', 'integer',array('limit' => 20,  'default' => 0,'comment' => '时长(试卷类型选择了定时类型时有值，其他时间为0)'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();




        $table = $this->table('audit_exam_file', ['comment' => '审核问卷文件表']);
        $table
            ->addColumn('audit_exam_id', 'integer',array('limit' => 30,'default' => 0,'comment' => '审核问卷表id'))
            ->addColumn('user_id', 'integer',array('limit' => 30, 'default' => 0,'comment' => '提交人id'))
            ->addColumn('exam_id', 'integer',array('limit' => 50,'default' => 0,'comment' => '问卷id'))
            ->addColumn('exam_stair_type_id', 'integer', array('limit' => 30, 'default' => 1, 'comment' => '一级'))
            ->addColumn('exam_second_level_id', 'integer', array('limit' => 30, 'default' => 1, 'comment' => '二级'))
            ->addColumn('exam_detail_id', 'integer', array('limit' => 30, 'default' => 1, 'comment' => '具体细则表id'))
            ->addColumn('file_path', 'json', array('null' => true, 'comment' => '问卷文件表'))
            ->addColumn('content', 'text', array('null' => true, 'comment' => '描述'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
